Many applications require traversal of a file system or other hierarchical data structure. For example, searching through a file system requires reading through the entire directory structure in order to process every file in the system. A file system is represented as a hierarchical tree data structure with each directory as a branch and each file as a leaf. Traditionally traversal of such a tree data structure is accomplished using a recursive algorithm such as the following function:                1. Read an entry in the current directory.        2. If it is a directory, set the current directory to the new directory and recursively reenter this function.        3. If there are no more entries exit this function.        4. Go back to step one to read the next entry.        
This traditional method has limitations due to its recursive nature—the function calls itself over and over again. Since each function call can incur large amounts of computational and memory overhead, traversing a very deep directory structure can cause a program crash, e.g., due to insufficient call stack space. Also deep recursive function calls can hinder application performance. Therefore, there is a need for a way to traverse hierarchical data structures more efficiently.